package com.second.app.thread.reentrant.a;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author gyz
 * @date 2021/2/1 13:55
 */
public class ReentrantLockService {

    private final ReentrantLock reentrantLock = new ReentrantLock();

    public void testMethod() {
        reentrantLock.lock();
        try {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() + ":" + (i + 1));
            }
        } finally {
            reentrantLock.unlock();
        }

    }

}
